home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / lib / mathlib / libconv / TRY / ornl_dcor2d.f < prev    next >
Encoding:
Text File  |  1994-08-02  |  3.6 KB  |  110 lines

  1.       subroutine ornl_dcor2d(    f,incf,ldf,ifx0,n_fx,ify0,n_fy,
  2.      $                g,incg,ldg,igx0,n_gx,igy0,n_gy,
  3.      $                h,inch,ldh,ihx0,n_hx,ihy0,n_hy)
  4.       double precision f(ldf,n_fy)
  5.       double precision g(ldg,n_gy)
  6.       double precision h(ldh,n_hy)
  7.       integer incf,ldf,ifx0,n_fx,ify0,n_fy
  8.       integer incg,ldg,igx0,n_gx,igy0,n_gy
  9.       integer inch,ldh,ihx0,n_hx,ihy0,n_hy
  10. c-----------------------------------------------------------------------------
  11. c
  12. c   dcor2d  performs a 2D correlation in the Space domain :
  13. c    h(i,j) = Sum[ f(k,l) * g(i+k,j+l) ]
  14. c
  15. c-----------------------------------------------------------------------------
  16. c
  17. c   PARAMETERS:
  18. c
  19. c    f:    Vector containing sequence "f"
  20. c    ldf:    Increment between two successive columns of "f"
  21. c    nfx1:    Index of the first element of each column of "f"
  22. c    nfx2:    Index of the  last element of each column of "f"
  23. c    nfy1:    Index of the first column of "f"
  24. c    nfy2:    Index of the  last column of "f"
  25. c    
  26. c    g:    Vector containing sequence "g"
  27. c    ldg:    Increment between two successive columns of "g"
  28. c    ngx1:    Index of the first element of each column of "g"
  29. c    ngx2:    Index of the  last element of each column of "g"
  30. c    ngy1:    Index of the first column of "g"
  31. c    ngy2:    Index of the  last column of "g"
  32. c    
  33. c    h:    Vector containing sequence "h"
  34. c    ldh:    Increment between two successive columns of "h"
  35. c    nhx1:    Index of the first element of each column of "h"
  36. c    nhx2:    Index of the  last element of each column of "h"
  37. c    nhy1:    Index of the first column of "h"
  38. c    nhy2:    Index of the  last column of "h"
  39. c    
  40. c-----------------------------------------------------------------------------
  41. c
  42. c   PLEASE NOTE:
  43. c    Please note that the array pointers must all point to the first 
  44. c    element of the array "(nfx1,nfy1)", "(ngx1,ngy1)" and "(nhx1,nhy1)"
  45. c     If "f" for example is defined as
  46. c        dimension f(-25:45,10:21)
  47. c    Then "dcor2d" must be called with the following parameters
  48. c        call dcor2d( f(-25,10),(45-(-25)+1),-25,45,10,21 ... )
  49. c
  50. c-----------------------------------------------------------------------------
  51. c
  52. c   This Fortran Subroutine written by
  53. c    Jean-Pierre Panziera
  54. c    Silicon Graphics Inc
  55. c    September 9, 1991
  56. c
  57. c-----------------------------------------------------------------------------
  58.  
  59.       double precision tmp, zero, one
  60.       parameter (zero = 0.0, one = 1.0)
  61.       integer i,j,k,j0,j1,k1,k2,ify1,igy1,ihy1,ix,jh,jf,jg,ig,igx1
  62. c-----------------------------------------------------------------------------
  63. c
  64. c   Compute Range
  65. c
  66. c-----------------------------------------------------------------------------
  67.     ify1 = ify0 + n_fy - 1
  68.     igy1 = igy0 + n_gy - 1
  69.     ihy1 = ihy0 + n_hy - 1
  70.  
  71.     igx1 = igx0 + n_gx - 1
  72.     ig   = 1 + (igx1-igx0) * incg
  73.  
  74.     j0 = max( ihy0, ify0-igy1)
  75.     j1 = min( ihy1, ify1-igy0)
  76. c-----------------------------------------------------------------------------
  77. c
  78. c   Zero the Resulting sequence
  79. c
  80. c-----------------------------------------------------------------------------
  81.     do j = ihy0, ihy1
  82.         ix = 1
  83.         jh = j-ihy0 + 1
  84.         do i = 1, n_hx
  85.             h(ix,jh) = zero
  86.         ix = ix + inch
  87.         end do
  88.     end do
  89. c-----------------------------------------------------------------------------
  90. c
  91. c   Then Compute the correlation
  92. c
  93. c-----------------------------------------------------------------------------
  94.     do j = j0, j1
  95.         k1 = max( -igy1, j-ify1)
  96.         k2 = min( j-ify0, -igy0)
  97.         jh = j -ihy0+1
  98.         do k = k1, k2
  99.         jf = j-k -ify0+1
  100.         jg = -k  -igy0+1
  101.         call dfir1d(    f(1,jf), incf, ifx0, n_fx,
  102.      $                g(ig,jg), -incg, -igx1, n_gx,
  103.      $                h(1,jh), inch, ihx0, n_hx,
  104.      $                one, one)
  105.         end do
  106.     end do
  107. c-----------------------------------------------------------------------------
  108.       return
  109.       end
  110.